package com.cvte.vdt.uartservice.util;

/**
 * Created by Administrator on 2017/4/10 0010.
 */

import android.os.Build;
import android.util.Log;

import com.cvte.vdt.uartservice.BuildConfig;

/**
 * @author user
 */
public final class LogUtil {
    private static boolean logOnFlag = BuildConfig.DEBUG;

    private static final String LOG = "[LogUtil]:";

    private LogUtil() {
    }

    public static void v(String tag, String msg) {
        if (logOnFlag) {
            Log.v(tag, LOG + msg);
        }
    }

    public static void v(String tag, String msg, Throwable tr) {
        if (logOnFlag) {
            Log.v(tag, LOG + msg, tr);
        }
    }

    public static void d(String tag, String msg) {
        if (logOnFlag) {
            Log.d(tag, LOG + msg);
        }
    }

    public static void d(String tag, String msg, Throwable tr) {
        if (logOnFlag) {
            Log.d(tag, LOG + msg, tr);
        }
    }

    public static void i(String tag, String msg) {
        if (logOnFlag) {
            Log.i(tag, LOG + msg);
        }
    }

    public static void i(String tag, String msg, Throwable tr) {
        if (logOnFlag) {
            Log.i(tag, LOG + msg, tr);
        }
    }

    public static void w(String tag, String msg) {
        if (logOnFlag) {
            Log.w(tag, LOG + msg);
        }
    }

    public static void w(String tag, String msg, Throwable tr) {
        if (logOnFlag) {
            Log.w(tag, LOG + msg, tr);
        }
    }

    public static void e(String tag, String msg) {
        if (logOnFlag) {
            Log.e(tag, LOG + msg);
        }
    }

    public static void e(String tag, String msg, Throwable tr) {
        if (logOnFlag) {
            Log.e(tag, LOG + msg, tr);
        }
    }

    public static void printStackTrace() {
        Throwable tr = new Throwable();
        Log.getStackTraceString(tr);
        tr.printStackTrace();
    }

}
